package com.lagou.service.impl;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.TimeUnit;

@Service
public class HelloServiceImpl implements HelloService {

    /**
     * 随机获取休眠时间
     */
    private int getRandomSleepTime() {
        return (int) (Math.random() * 100);
    }


    @Override
    public String sayHelloA(String name) {
        try {
            TimeUnit.MILLISECONDS.sleep(getRandomSleepTime());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "helloA:" + name;
    }


    @Override
    public String sayHelloB(String name) {
        try {
            TimeUnit.MILLISECONDS.sleep(getRandomSleepTime());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "helloB:" + name;
    }

    @Override
    public String sayHelloC(String name) {
        try {
            TimeUnit.MILLISECONDS.sleep(getRandomSleepTime());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "helloC:" + name;
    }

}
